package net.worthtech.callcasher;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

/**
 * Created by RigerWu on 2019-12-04.
 */
public class CardRefundActivity extends AppCompatActivity {

    private EditText mTime;
    private EditText mReferNum;
    private EditText mMoney;
    private Button mBtnRefund;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card_refund);
        mTime = (EditText) findViewById(R.id.time);
        mReferNum = (EditText) findViewById(R.id.refer_num);
        mMoney = (EditText) findViewById(R.id.money);
        mBtnRefund = (Button) findViewById(R.id.btn_refund);


        mBtnRefund.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String time = mTime.getText().toString();
                String referNum = mReferNum.getText().toString();
                String money = mMoney.getText().toString();

                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "cardRefund");
                intent.putExtra("amount", money);

                intent.putExtra("referenceNo", referNum);
                intent.putExtra("dateInfo", time);
                startActivityForResult(intent, 0);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 0 && data != null) {
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("result"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("paytype"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("trace"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("referenceNo"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("amount"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("printInfo"));
        }
    }
}
